// pf_lib.cpp : ���Ӧ����ڵ㡣
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <include/pf_base64.h>



int main()
{
    char   test_string1[] = "";
    char   test_string2[] = "Hello world1";
    char   test_string3[] = "Hello world11";
    const  char* last_2 = "+@";
    
    char*   output_string1 = (char*)malloc(sizeof(char)*100);
    char*   output_string2 = (char*)malloc(sizeof(char)*100);
    char*   output_string3 = (char*)malloc(sizeof(char)*100);
    
    char*   back_string1 = (char*)malloc(sizeof(char)*100);
    char*   back_string2 = (char*)malloc(sizeof(char)*100);
    char*   back_string3 = (char*)malloc(sizeof(char)*100);
    
    int32_t out_len1 = 0;
    int32_t out_len2 = 0;
    int32_t out_len3 = 0;
    
    int32_t back_len1 = 0;
    int32_t back_len2 = 0;
    int32_t back_len3 = 0;
    int32_t ret = 0; 
    int32_t ret1 = 0; 
    
    out_len1 = pf_base64_get_len(strlen((char* )test_string1),1);
    ret = pf_base64_encode((const void*) test_string1,strlen((char* )test_string1),output_string1,100,last_2);
    back_len1 = pf_base64_get_len((int32_t)strlen((char *)output_string1),2);
    ret1 = pf_base64_decode((char*) output_string1,strlen((char*)output_string1),(void*)back_string1,100,last_2);
	
	printf("out_len is :%d,back_len is %d,true out_len is: %d,true back_len is:%d,ret is:%d,ret1 is %d\n",(int)out_len1,(int)back_len1,(int)strlen((char *)output_string1),(int)strlen((char *)back_string1),ret,ret1);
	printf("original string is:%s\n",test_string1);
	printf("out string is:%s\n",output_string1);
	printf("back string is:%s\n",back_string1);
	
    out_len2 = pf_base64_get_len(strlen((char *)test_string2),1);
    ret = pf_base64_encode((const void*) test_string2,strlen((char *)test_string2),(char*)output_string2,out_len2,last_2);
    back_len2 = pf_base64_get_len(strlen((char *) output_string2),2);
    ret1 = pf_base64_decode((char*) output_string2,strlen((char *)output_string2),(void*)back_string2,back_len2,last_2);
	
	printf("out_len is :%d,back_len is %d,true out_len is: %d,true back_len is:%d\n",out_len2,back_len2,(int)strlen((char *)output_string2),(int)strlen((char *)back_string2));
	printf("original string is:%s\n",test_string2);
	printf("out string is:%s\n",output_string2);
	printf("back string is:%s\n",back_string2);
	printf("ret is:%d\n",ret);
	printf("ret1 is:%d\n",ret1);
    
    out_len3 = pf_base64_get_len(strlen((char *)test_string3),1);
    pf_base64_encode((const void*) test_string3,strlen((char *)test_string3),(char*)output_string3,out_len3+1,last_2);
    back_len3 = pf_base64_get_len(strlen((char *)output_string3),2);
    pf_base64_decode((char*) output_string3,strlen((char *)output_string3),(void*)back_string3,back_len3+1,last_2);
	
	printf("out_len is :%d,back_len is %d,true out_len is: %d,true back_len is:%d\n",out_len3,back_len3,(int) strlen((char *)output_string3),(int) strlen((char *) back_string3));
	printf("original string is:%s\n",test_string3);
	printf("out string is:%s\n",output_string3);
	printf("back string is:%s\n",back_string3);
	
	free(output_string1);
	free(output_string2);
	free(output_string3);
	free(back_string1);
	free(back_string2);
	free(back_string3);
	
	return 0;
}

